import { ETaskState } from "GameLoop/DecisionMaking/TaskDeclare/type";
 
export class RoomTaskChecker
{
    public static notify:Notify
    public static check(room:Room,task:ITaskDeclare["room"])
    {
        switch(task.data.type)
        {
            case "placePlan":
                return this.checkPlacePlan(room,task as any);
            case "observe":
                return this.checkObserve(room,task as any)
                ;
            default:
                room.log("warn","未知的任务类型",JSON.stringify(task))
                return ETaskState.Complete;
        }
       
    }
    private static checkPlacePlan(room:Room,task:ITask<IRoomTaskData<"placePlan">>):ETaskState
    {
        if(task.data.arg.plan.length == 0)
        {
            this.notify(room.name,{type:"PlaceSite",region:room.lordRoom().name,room:task.data.arg.roomName});
            return ETaskState.Complete;
        }
        return ETaskState.Running;
    }
    
    private static checkObserve(room:Room,task:ITask<IRoomTaskData<"observe">>):ETaskState
    {
        if(task.data.arg.rooms.length ==0)
        {
            return    ETaskState.Complete;
        }
       
        
        return ETaskState.Running;
    }
}